<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
#msgZone{
width:500px;
height:360px;	
}
#msg {
border: solid 1px gray;
width:500px;
height:330px;
overflow:scroll;
}
</style>
<script src="../js/jquery-2.0.js"></script>
<script type = "text/javascript">
$(document).ready(function(){
var msg=$('#msg').html();
$('#btn').click(function(){
 msg+='hhhhhhh';
 msg+='<br>';
$('#msg').html(msg);		
	});
	
$('#btn1').click(function(){
  alert($('#msg').html());
  });
});


</script>
</head>
<body>
<div id=msgZone>
<div id='msg'>
</div>
<input type="button" id='btn' value='发送'/>
<input type="button" id='btn1' value='获取内容'/>
</div>
</body>
<script type = "text/javascript">
// 长轮询
var setting = {
url:'comet.php',
type:'get',
dataType:'json',
cache: false, 
success:function(res) { 
    //console.log(res);
    $('<p>xx对你说<br />'+res['content']+'</p>').appendTo($('#msg'));
    //window.setTimeout(function(){$.ajax(setting)},1000);
	setTimeout($.ajax(setting),1000);
   }
};
$.ajax(setting);
</script>
</html>
